import { defineStore } from "pinia";
import Cookies from "js-cookie";

const cookiesStorage: any = {
  setItem(key: string, state: any) {
    return Cookies.set(key, state.accessToken, { expires: 3 });
  },
  getItem(key: string) {
    return JSON.stringify({ accessToken: Cookies.get(key) });
  },
};

let setRoomNumber = defineStore("setRoomNumber", {
  persist: {
    enabled: true,
    strategies: [
      {
        storage: sessionStorage,
        paths: ["roomName"],
      },
    ],
  },

  state: () => {
    return {
      roomName: "",
    };
  },
  getters: {},
  actions: {
    setRoomName(name: string) {
      this.roomName = name;
    },
  },
});

export default setRoomNumber;
